package com.suiwei.advanced.algorithm;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;

/**
 * @author suiwei
 * @date 2023/3/26 23:09
 */
@Slf4j
public class Maths {
  /** 数字拆分 */
  @Test
  void numberSplit() {
    int num = 123;
    int ge = num % 10;
    int shi = num / 10 % 10;
    int bai = num / 100;
  }

  /** 水仙花数 */
  @Test
  void narcissus() {
    for (int i = 100; i <= 999; i++) {
      int ge = i % 10;
      int shi = i / 10 % 10;
      int bai = i / 100;
      if (ge * ge * ge + shi * shi * shi + bai * bai * bai == i) {
        System.out.println(i);
      }
    }
  }

  @Test
  void multiplication99() {
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= i; j++) {
        System.out.print(j + "*" + i + "=" + j * i + "\t");
      }
      System.out.println();
    }
  }
}
